package rule.rulechain;

import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

import java.io.File;

/**
 * Created by fengxiangxiang on 2016-10-14.
 */
public class DeleteFile implements TestRule {
    public DeleteFile(String file) {
        File oldFile = new File(file);
        if (oldFile.exists()) {
            oldFile.delete();
        }
        System.out.println("start deleting file");
    }

    @Override
    public Statement apply(final Statement statement,final Description description) {
        System.out.println("Step1:old file is deleted");
        return statement;
    }
}
